The main function of the database